using Godot;

namespace RoboRampage.Player;

public partial class SmoothCamera3d : Camera3D
{
    [Export] public float ExSpeed = 80f; // 相机旋转速度

    // 重写父类方法，实现相机平滑旋转
    public override void _PhysicsProcess(double delta)
    {
        // 计算权重，限制在0-1之间
        var weight = (float)Mathf.Clamp(delta * ExSpeed, 0f, 150f);
        // 使用插值方法实现相机平滑旋转
        GlobalTransform = GlobalTransform.InterpolateWith(((Node3D)GetParent()).GlobalTransform, weight);

        GlobalPosition = ((Node3D)GetParent()).GlobalPosition;
    }
}